import java.util.*;

public class CalendarSeeker {
	
		public static void main(String [] args) {
						
						//day input
	                    Scanner in = new Scanner(System.in);
						System.out.println("Enter day: ");
						int day = in.nextInt();
						
						//month input
						System.out.println("Enter month: ");
						String monthInput = in.next();
						
						//I tried to get months number using array or enum types, but it didn't work,
						//so for now I left this 'if else' variant...
						int month = 0;
						if(monthInput.equalsIgnoreCase("january")){
							month = 1;
						}
						else if(monthInput.equalsIgnoreCase("february")){
							month = 2;
						}
						else if(monthInput.equalsIgnoreCase("march")){
							month = 3;
						}
						else if(monthInput.equalsIgnoreCase("april")){
							month = 4;
						}
						else if(monthInput.equalsIgnoreCase("may")){
							month = 5;
						}
						else if(monthInput.equalsIgnoreCase("june")){
							month = 6;
						}
						else if(monthInput.equalsIgnoreCase("july")){
							month = 7;
						}
						else if(monthInput.equalsIgnoreCase("august")){
							month = 8;
						}
						else if(monthInput.equalsIgnoreCase("september")){
							month = 9;
						}
						else if(monthInput.equalsIgnoreCase("october")){
							month = 10;
						}
						else if(monthInput.equalsIgnoreCase("november")){
							month = 11;
						}
						else if(monthInput.equalsIgnoreCase("december")){
							month = 12;
						}						
						
						//year input
						System.out.println("Enter year between 1900 and 2100: ");
						int year = in.nextInt();   
	                    
						/*
						 I didn't make check for wrong input values 
						 'cause I don't really now how to do it correctly.
						*/
												
						//calculate day of the week
	                    int dayOfTheWeek = (year - 1900) * 365 + (year - 1900) / 4;
	                    if (year % 4 == 0 && month <= 2) {
	                            dayOfTheWeek--;
	                    }
	                    switch (month) {
	                    case 12: dayOfTheWeek += 30; 
	                    case 11: dayOfTheWeek += 31;
	                    case 10: dayOfTheWeek += 30;
	                    case 9: dayOfTheWeek += 31;
	                    case 8: dayOfTheWeek += 31;
	                    case 7: dayOfTheWeek += 30;
	                    case 6: dayOfTheWeek += 31;
	                    case 5: dayOfTheWeek += 30;
	                    case 4: dayOfTheWeek += 31;
	                    case 3: dayOfTheWeek += 28;                     
	                    case 2: dayOfTheWeek += 31;
	                }
	            
	                    dayOfTheWeek = (day + dayOfTheWeek) % 7;
	                    
	                    switch (dayOfTheWeek) {
	                    case 0: System.out.println("Sunday");
	                            break;
	                    case 1: System.out.println("Monday");
	                            break;
	                    case 2: System.out.println("Tuesday");
	                            break;
	                    case 3: System.out.println("Wednesday");
	                            break;
	                    case 4: System.out.println("Thursday");
	                            break;  
	                    case 5: System.out.println("Friday");
	                            break;
	                    case 6: System.out.println("Saturday");
	                            break;
	                    }
						System.out.println(dayOfTheWeek);
	            }

}
